package model

import "github.com/jinzhu/gorm"

// 盲盒表
type BindBox struct {
	gorm.Model
	BoxName    *string  `json:"box_name" gorm:"column:box_name"`       //盲盒名称
	BoxPrice   *float64 `json:"box_price" gorm:"column:box_price"`     //盲盒价格
	BoxCover   string   `json:"box_cover" gorm:"column:box_cover"`     //盲盒封面
	BoxDetails string   `json:"box_details" gorm:"column:box_details"` //盲盒详情
	BoxVolume  int      `json:"box_volume" gorm:"column:box_volume"`   //盲盒销量
	BoxPcs     []BoxPc  `json:"box_pc_list" gorm:"foreignkey:BoxId;association_foreignkey:ID"`
}

func (BindBox) TableName() string {
	return "mh_binbox"
}

// 盲盒批次表
type BoxPc struct {
	gorm.Model
	BatchNo     string       `json:"batch_no" gorm:"column:batch_no"` //批次编号
	BoxId       uint         `json:"box_id" gorm:"column:box_id"`     //盲盒ID
	BatchPrizes []BatchPrize `json:"batch_prizes_list" gorm:"foreignkey:BoxId,BoxPcId;association_foreignkey:BoxId,ID"`
}

func (BoxPc) TableName() string {
	return "mh_boxpc"
}

// 奖品表
type BatchPrize struct {
	gorm.Model
	BoxId       uint    `json:"box_id"gorm:"column:box_id"`            //盲盒ID
	BoxPcId     uint    `json:"box_pc_id" gorm:"column:box_pc_id"`     //批次ID
	GoodId      uint    `json:"good_id" gorm:"column:good_id"`         //商品ID
	GoodName    string  `json:"good_name"`                             //商品名称
	GoodCover   string  `json:"good_cover"`                            //商品图片
	PrizeNum    int     `json:"prize_num" gorm:"column:prize_num"`     //奖品数量
	Probability float64 `json:"probability" gorm:"column:probability"` //中奖概率
}

func (BatchPrize) TableName() string {
	return "mh_box_batchPrize"
}
